import request from "@/utils/request";
import { APP_ID, APP_SECRET } from "@/enums/CacheEnum";
import type {SessinoCode,SeatConversation} from "./types";

class AiServ {
	/**
	 * 创建新的客服动话
	 */
	static postsession(AuthorizeCode: string,data:SessinoCode) {
		return request<any>({
			url: "/api/aiserv/session",
			method: "post",
			data: data,
			headers: {
				token: AuthorizeCode,
			},
		});
	}
	/**
	 * 创建新的坐席会话
	 */
	static postSeatSession(AuthorizeCode: string,data:any) {
		const formData = new FormData()
		formData.append('stream',data.stream)
		if (data.request!='') {
			formData.append('request',data.request)
		}
		if (data.character!='') {
			formData.append('character',data.character)
		}
		if (data.certain_info=='') {
			formData.append('certain_info',data.certain_info)
		}
		return request<any>({
			url: "/api/aiserv/seat-session",
			method: "post",
			data: formData,
			headers: {
				token: AuthorizeCode,
			},
		});
	}
	/**
	 * 向客服AI提问
	 */
	static postanswer(token: string,SessionCode:string,data:string) {
		const formData = new FormData();
		formData.append("session_code", SessionCode);
		formData.append("question", data);
		return request<any>({
			url: "/api/aiserv/answer",
			method: "post",
			data: formData,
			headers: {
				token: token,
				"Content-Type": "application/json",
			},
		});
	}
	/**
	 * 获取坐席会话的案件信息
	 */
	static postSeatInfo(AuthorizeCode: string,code:any,data:any) {
		const formData = {
			session_code:code,
			session_type:data,
		}
		return request<any>({
			url: "/api/aiserv/save-info",
			method: "get",
			params:formData,
			headers: {
				token: AuthorizeCode,
			},
		});
	}
	/**
	 * 暂时获取历史会话案件信息
	 * 
	 */
	static hostorySession(AuthorizeCode: string,code:any) {
		const formData = {
			session_code:code,
		}
		return request<any>({
			url: "/api/aiserv/history-session-case",
			method: "get",
			params:formData,
			headers: {
				token: AuthorizeCode,
			},
		});
	}
	/**
	 * 新建卡槽式反问
	 */
		static postSlotsSession(AuthorizeCode: string,data:any) {
			// console.log('data=',data);
			return request<any>({
				url: "/api/aiserv/slots-session",
				method: "post",
				data: data,
				headers: {
					token: AuthorizeCode,
				},
			});
		}
	/**
	 * 获取槽位信息
	 */
		static getAIservSlots(AuthorizeCode: string,code:any,data:any) {
			const formData = {
				session_code:code,
				session_type:data,
			}
			return request<any>({
				url: "/api/aiserv/slots",
				method: "get",
				params:formData,
				headers: {
					token: AuthorizeCode,
				},
			});
		}
	/**
	 * 给会话评分
	 */
		static getSessionRate(AuthorizeCode: string,data:any) {
			
			const formData = {
				session_code:data.session_code,
			}
			return request<any>({
				url: "/api/aiserv/session-score",
				method: "get",
				params:formData,
				headers: {
					token: AuthorizeCode,
				},
			});
		}	
}
export default AiServ;